{% extends "project/base.html" %}
{% block content %}
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content mailbox-content">
                        <div class="file-manager">
                            <div class="space-25"></div>
                            <h4>课程信息：</h4>
                            <ul class="folder-list m-b-md" style="padding: 0">
                                <li>
                                    <a href="#"> <span class="glyphicon glyphicon-book"></span> &nbsp;&nbsp;课程名称： {{ course.cname }} </a>
                                </li>
                                <li>
                                    <a href="#"><span class="glyphicon glyphicon-book"></span> &nbsp;&nbsp;班级： {{ course.classes }}</a>
                                </li>
                                <li>
                                    <a href="#"> <span class="glyphicon glyphicon-user"></span> &nbsp;&nbsp;授课教师： {{ course.teacher.name }}</a>
                                </li>
                                <li>
                                    <a href="#"> <span class="glyphicon glyphicon-list-alt"></span> &nbsp;&nbsp;课程描述： {{ course.description }}</a>
                                </li>
                            </ul>
                            {% if request.user.role.role == 0 %}
                            <h4>课程作业</h4>
                            <ul class="category-list" style="padding: 0">
                                <ul class="category-list" style="padding: 0">
                                    <li>
                                        <a href="{% url 'project:homework_list' course.id %}"> <i class="fa fa-circle text-navy"></i> 所有作业</a>
                                    </li>
                                    <li>
                                        <a href="{% url 'project:handin_list_done' course.id %}"> <i class="fa fa-circle text-danger"></i> 已提交作业</a>
                                    </li>
                                </ul>
                            </ul>
                            <h4 class="tag-title">学生信息：</h4>
                            <ul class="tag-list" style="padding: 0">
                                <li><a href="#"><span class="glyphicon glyphicon-user"></span> {{ request.user.role.student.name }}</a></li>
                            </ul>
                            <div class="clearfix"></div>
                            <div class="space-25"></div>
                            <a class="btn btn-block btn-primary compose-mail" href="{% url 'project:course_cancel' course.id %}" >退出课程</a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9 animated fadeInRight">
                <div class="mail-box-header">
                    <form method="get" action="#" class="pull-right mail-search">
                        <div class="input-group">
                            <input type="text" class="form-control input-sm" name="search" placeholder="请输入搜索内容 ...">
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                    <h2>所有作业列表 </h2>
                    <div class="mail-tools tooltip-demo m-t-md">
                    </div>
                </div>
                <div class="mail-box">
                    <table class="table table-hover table-mail">
                        <tbody>
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="ibox-content">
                                        <table class="footable table table-stripped" data-page-size="8" data-filter=#filter>
                                            <tbody align="center">
{% if info %}
<table class="table table-striped">
    <thead>
        <tr>
            <th></th>
            <th>标题</th>
            <th>所属课程</th>
            <th>发布日期</th>
            <th>查看</th>
            <th>附件格式</th>
            <th>下载附件</th>
            <th>提交</th>
            <th>分数</th>
        </tr>
    </thead>
    <tbody>
        {% for object,judge,score in info %}
        <tr>
            <td></td>
            <td>
            {{ object.title }}
            </td>
            <td>
            {{ object.course.cname }}
            </td>
            <td>
            {{ object.published | date:"Y-m-d" }}
            </td>
            <td>
                    <a href="{% url 'project:homework_detail' course.id object.id %}"><span class="glyphicon glyphicon-eye-open"></span></a>
            </td>
            <td>
                {% if object.file %}
                    {{ object.get_format }}
                {% endif %}
            </td>
            <td>
                {% if object.file %}
                    <a href="{{ object.file.url }}"><span class="glyphicon glyphicon-download"></span></a>
                {% endif %}
            </td>
            <td>
                {% if not judge %}
                    <a href="{% url 'project:handin_create' course.id object.id %}">提交</a>
                {% else %}
                    已提交
                {% endif %}
            </td>
            <td>
                {{ score }}
            </td>
        {% endfor %}
        </tr>
    </tbody>
</table>

{% else %}
{# 注释: 这里可以换成自己的对象 #}
<table class="table table-striped">
    <tr>
        <td>&nbsp;</td>
        <td>对不起，没有作业。</td>
    </tr>
</table>
{% endif %}

{# 注释: 下面代码一点也不要动 #}
{% if is_paginated %}
        <ul class="pagination">
    {% if page_obj.has_previous %}
        <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">Previous</a></li>
    {% else %}
        <li class="page-item disabled"><span class="page-link">Previous</span></li>
    {% endif %}

    {% for i in paginator.page_range %}
        {% if page_obj.number == i %}
        <li class="page-item active"><span class="page-link"> {{ i }} <span class="sr-only">(current)</span></span></li>
        {% else %}
        <li class="page-item"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li>
        {% endif %}
    {% endfor %}
        {% if page_obj.has_next %}
        <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">Next</a></li>
    {% else %}
        <li class="page-item disabled"><span class="page-link">Next</span></li>
    {% endif %}
    </ul>

{% endif %}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
{% endblock %}